import Cookies from "js-cookie";
import router from '@/router'
import {getQuery} from "@/utils"
//先判断url是否有值
const menuId  = getQuery(window.location.href).menuId;
//如果有值，保存进cookies
if (menuId) {
  console.log(menuId,'dsada')
  Cookies.set("epm_productId", menuId);
  // this.$router.redirect("/welcome");
}
const state = {
  productId: Cookies.get("epm_productId")||""
}

const mutations = {
  CHANGE_PRODUCT: (state,  productId ) => {
    state.productId = productId
  }
}

const actions = {
  changeProduct({ commit }, productId) {
    Cookies.set("epm_productId",productId)
    commit('CHANGE_PRODUCT', productId)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

